/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ejb.webservice;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;

/**
 *
 * @author Ambroise
 */
@WebService(serviceName = "CreditCard")
@Stateless()
public class CreditCard {

    @WebMethod(operationName = "checkCreditCard")
    public boolean checkCreditCard(@WebParam(name = "creditCard") String creditCard) {
        creditCard = creditCard.trim().replaceAll(" ", "");
        System.out.println("WebService credit card number detected: "+creditCard);
        if (creditCard != null && creditCard.length() >= 14 && creditCard.length() <= 16){
            return true;
        }else{
            return false;
        }
    }
}
